﻿using MediatR;
using T_Material.API.Application.Commands.PurchaseCommand;
using T_Material.API.Application.Commands.WarehousingCommand;
using T_Material.Domain;
using T_Material.Infrastructure.ImpI;
using T_Material.Infrastructure.Interface;

namespace T_Material.API.Application.CommandHandlers.WarehousingHandlers
{
    public class WarehousingCreatedCommandHandler : IRequestHandler<WarehousingCreatedCommand, int>
    {

        private readonly IWarehousingRepository warehousingRepository;
        public WarehousingCreatedCommandHandler(IWarehousingRepository warehousingRepository)
        {
            this.warehousingRepository = warehousingRepository;
        }

        public async Task<int> Handle(WarehousingCreatedCommand request, CancellationToken cancellationToken)
        {
            var info = new Warehousing();
            info.Id = request.Id;
            info.GoodsName = request.GoodsName;
            info.TypeName = request.TypeName;
            info.Specs = request.Specs;
            info.Country = request.Country;
            info.Province = request.Country;
            info.Province = request.Province;
            info.ModeOfPayment = request.ModeOfPayment;
            info.BuyMoney = request.BuyMoney;
            info.RegPerson = "小亮";
            info.Remarks = request.Remarks;
            info.MateriaQluality = request.MateriaQluality;
            info.Quantity = request.Quantity;
            info.Price=request.Price;
            info.CreateBy = "张三";
            info.CreateDate = DateTime.Now;
            info.UpdateBy = "";
            info.UpdateDate = null;
            info.IsDel = false;
            var res = await warehousingRepository.Addsync(info);
            return res;
        }
    }
}
